import request from '@/utils/request';

export async function getDrawingReviewByPage(params: any) {
  return request('/api/design/getDrawingReviewByPage', {
    method: 'POST',
    data: params,
  });
}

export async function addDrawingReview(params: any) {
  return request('/api/design/addDrawingReview', {
    method: 'POST',
    data: params,
  });
}

export async function updateDrawingReview(params: any) {
  return request('/api/design/updateDrawingReview', {
    method: 'POST',
    data: params,
  });
}

export async function delDrawingReview(params: any) {
  return request('/api/design/delDrawingReview', {
    method: 'POST',
    data: params,
  });
}

export async function exportDrawingReview(params: any) {
  return request('/api/design/exportDrawingReview', {
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}

/**
 * @description: 实现预览下载功能，获取最新的文件url
 * @param {any} params
 * @return {*}
 */
export async function getDrawingInfoPreviewUrl(params: any) {
  return request('/api/design/getDrawingInfoPreviewUrl', {
    method: 'POST',
    // data: params,
    // responseType: 'blob',
    params: {
      drawingId: params.drawingId,
    },
  });
}

// 图纸审核
export async function confirmDrawingReview(para: any) {
  return request('/api/design/confirmDrawingReview', {
    method: 'POST',
    requestType: 'form',
    params: {
      id: para.id,
      reviewState: para.reviewState,
      reviewMemo: para.reviewMemo,
      version: para.version,
    },
  });
}

export default {
  getDrawingReviewByPage,
  addDrawingReview,
  updateDrawingReview,
  delDrawingReview,
  exportDrawingReview,
  getDrawingInfoPreviewUrl,
};
